package com.joysuch.wwyt.bp.service;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joysuch.wwyt.bp.bean.BpHiddenDangerBean;
import com.joysuch.wwyt.bp.bean.BpTaskInvestigateBean;
import com.joysuch.wwyt.bp.bean.TaskListExcelBean;
import com.joysuch.wwyt.bp.bean.investigate.TaskDelBean;
import com.joysuch.wwyt.bp.bean.investigate.TaskDelDTO;
import com.joysuch.wwyt.bp.bean.investigate.TaskSearchBean;
import com.joysuch.wwyt.bp.bean.investigate.TaskSearchVo;
import com.joysuch.wwyt.bp.bean.investigate.vo.TaskListVo;
import com.joysuch.wwyt.bp.bean.investigate.vo.TaskStatiGraphicalVo;
import com.joysuch.wwyt.bp.bean.investigate.vo.TaskVo;
import com.joysuch.wwyt.bp.bean.vo.TaskStatiUserVo;
import com.joysuch.wwyt.bp.entity.bean.SimpleInvTaskBean;
import com.joysuch.wwyt.bp.entity.bean.TaskTimeOutWaitingToDo;
import com.joysuch.wwyt.bp.entity.investigate.BpInvestigateRecordItem;
import com.joysuch.wwyt.bp.entity.investigate.BpInvestigateTask;
import com.baomidou.mybatisplus.extension.service.IService;
import com.joysuch.wwyt.bp.entity.vo.AppCheckTaskVo;
import com.joysuch.wwyt.bp.entity.vo.CheckRecordVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author heqifeng
 * @since 2022-04-07
 */
public interface BpInvestigateTaskService extends IService<BpInvestigateTask> {

    /**
     * 批量插入
     * @param taskList
     * @param batchSize
     */
    void batchSave(List<BpInvestigateTask> taskList, Integer batchSize);

    /**
     * 任务未检影响风险等级
     * @param recordItems
     * @param recordPlanMapping
     */
    void affectRiskLever(List<BpInvestigateRecordItem> recordItems, Map<Long,Long> recordPlanMapping);

    /**
     * 搜索未完成且已过期的（风险管控的）任务
     * @param currDate
     * @return
     */
    List<SimpleInvTaskBean> findDeadTask(Date currDate);

    /**
     * 搜索已开始，但不可做（计划处于隐患状态）的任务
     * @param currDate
     * @return
     */
    List<SimpleInvTaskBean> findCloseTask(Date currDate);

    Page<TaskListVo> getTaskRecordHistoryList(TaskSearchBean search);

    Page<TaskListVo> getTaskRecordHistoryNewList(TaskSearchBean search);

    /**
     * 查询需要导出的数据
     * @param search
     * @return
     */
    List<TaskListExcelBean> getTaskRecords(TaskSearchBean search);

    Long getTaskRecordCountAll();

    CheckRecordVo getRecordDetail(Long taskId);

    boolean deleteRecord(Long id);

    Page<TaskStatiUserVo> getStatistics(TaskSearchBean search);

    TaskStatiGraphicalVo getStatisticsGraphical(TaskSearchBean search);

    void exportReport(TaskSearchBean search, HttpServletRequest request, HttpServletResponse
            response) throws IOException;

    void newExportReport(TaskSearchBean search, HttpServletRequest request, HttpServletResponse
            response) throws IOException;

    void exportStatisticsList(TaskSearchBean search, HttpServletRequest request, HttpServletResponse response) throws IOException;

    /**
     * 批量更新任务完成状态
     * @param taskIds
     * @param status
     */
    int batchDown(List<Long> taskIds, String status);

    /**
     * 任务未检产生报警
     * @param waitingNotifyBeans
     */
    void sendMassageAndAlarm(List<TaskTimeOutWaitingToDo> waitingNotifyBeans);

    /**
     * 查询计划首个任务
     * @param planId
     * @return
     */
    BpInvestigateTask findByPlanId(Long planId);

    /**
     * 运行机制效果 隐患排查完成率统计
     * @param search
     * @return
     */
    BpTaskInvestigateBean getBpTaskInvestigateBean(TaskSearchBean search);


    /**
     * 运行机制效果 各部门隐患排查完成情况
     * @param search
     * @return
     */
    Page<BpTaskInvestigateBean> getTroubleshootingStatistics(TaskSearchBean search);

    /**
     * 运行机制效果 各部门隐患治理完成情况
     * @param search
     * @return
     */
    Page<BpHiddenDangerBean> getBpHiddenDangerBeanStatistics(TaskSearchBean search);

    /**
     * 运行机制效果  隐患治理完成率
     * @param search
     * @return
     */
    BpHiddenDangerBean getBpHiddenDangerBean(TaskSearchBean search);

    /**
     * 迁移数据
     */
    void moveData();

    void moveDataHand(Date border);

    Page<TaskVo> findTaskList(TaskSearchVo search);

    void deleteBatch(TaskDelDTO bean);

    BpInvestigateTask findOne(Long planId, Date checkDate, Date deadline);

    String deleteTask(TaskDelBean bean);

    List<BpInvestigateTask> findTodayTask(Long planId);

    List<AppCheckTaskVo.PointTaskGroup> selectByDistrictId(Long districtId, Long userId);

    Page<TaskListVo> getTaskRecordTodayList(TaskSearchBean search);

    void moveHisData();

    void moveHisDataDaily();

}
